# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Harish Rajagopal <harish dot rajagopals at gmail dot com>

_pkgname=ReGreet
pkgname=greetd-${_pkgname,,}
pkgver=0.1.1
pkgrel=1
pkgdesc='Clean and customizable greeter for greetd'
url="https://github.com/rharish101/$_pkgname"
license=(GPL3)
arch=(loong64 x86_64)
depends=(cage
         gcc-libs
         greetd
         gtk4)
provides=(greetd-greeter)
backup=("etc/greetd/${_pkgname,,}.toml")
makedepends=(cargo)
_archive="$_pkgname-$pkgver"
source=("$url/archive/$pkgver/$_archive.tar.gz"
        "${_pkgname,,}.toml")
sha256sums=('a658c91cdf242dfea814f0bfd0c4d877bd39e3af498d36e5024061e3d07ea76b'
            'b80b3eb31f8cc463d512c9db0eef899bdbe232d977429a8a12e95a3b6df2e387')

prepare() {
	cd "$_archive"
	cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
	cd "$_archive"
	cargo build --frozen --release --all-features
}

check() {
	cd "$_archive"
	cargo test --frozen --all-features
}

package() {
	cd "$_archive"
	install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/${_pkgname,,}"
	install -Dm0644 -t "$pkgdir/etc/greetd/" ../"${_pkgname,,}.toml"
	install -Dm0644 -t "$pkgdir/usr/share/doc/$pkgname/" "${_pkgname,,}.sample.toml"
	install -Dm0644 systemd-tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/${_pkgname,,}.conf"
}
